<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/6/22
 * Time: 11:06
 */

namespace app\admin\Decorate;
use app\admin\Imp\ImpDecorate;
use think\Request;
use think\Cache;
use think\Exception;
class CommitRepeatedly implements ImpDecorate
{


    public function beforeDecorate()
    {
        $token                          =   Request::instance()->header('authkey');
        if(Cache::has('headerAuth')){
            $headerAuth                 =   Cache::get('headerAuth');
            if($token==$headerAuth){throw new Exception('抱歉请不要做重复操作！',400);}
        }
        //没有的话那么储存当前的headerAuthKey以便下一提交的时候在做验证
        Cache::set('headerAuth',$token,0);
    }


    public function endDecorate()
    {
        // TODO: Implement endDecorate() method.
    }
}